package com.maojianjie.aimee.webautotest.browser;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

import com.maojianjie.aimee.webautotest.Browser;

public class RemoteFirefox extends Browser
{
	private String remoteAddress;

	public RemoteFirefox(String remoteAddress)
	{
		this.remoteAddress = remoteAddress;
	}

	@Override
	protected WebDriver createWebDriver()
	{
		try
		{
			WebDriver webDriver = new RemoteWebDriver(new URL(remoteAddress), DesiredCapabilities.firefox());
			webDriver.manage().timeouts().pageLoadTimeout(120, TimeUnit.SECONDS);
			webDriver.manage().timeouts().setScriptTimeout(120, TimeUnit.SECONDS);
			return webDriver;
		}
		catch (MalformedURLException e)
		{
			e.printStackTrace();
		}
		return null;
	}

}
